package cn.t.web.android;

import cn.t.annotation.Runtime;
import cn.t.converter.order.ReplenishmentDTOConverter;
import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.dto.android.ReplenishmentQueryPageRequest;
import cn.t.dto.order.android.ReplenishmentTotalDTO;
import cn.t.dto.order.repenlement.ReplenishmentPageDTO;
import cn.t.dto.order.repenlement.ReplenishmentQueryRequest;
import cn.t.facade.android.ReplenishmentAndroidFacade;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 设备端-补货管理
 * @author l
 */
@Slf4j
@RestController
@RequestMapping("runtime/replenishment")
@AllArgsConstructor
@Runtime
public class AndroidReplenishmentController {
    @Resource
    private ReplenishmentAndroidFacade replenishmentAndroidFacade;
    @Autowired
    private ReplenishmentDTOConverter replenishmentDTOConverter;

    /**
     * 补货单列表
     */
    @PostMapping(value = "/replenishmentList")
    public PageInfoDTO<ReplenishmentPageDTO> replenishmentList(@RequestBody ReplenishmentQueryPageRequest queryPageRequest) {
        PageQueryDTO<ReplenishmentQueryRequest> pageQueryDTO = new PageQueryDTO<>();
        pageQueryDTO.setPageNo(queryPageRequest.getPageNo());
        pageQueryDTO.setPageSize(queryPageRequest.getPageSize());
        pageQueryDTO.setParam(replenishmentDTOConverter.req2PageDTO(queryPageRequest));
        return replenishmentAndroidFacade.queryListPage(pageQueryDTO);
    }
    /**
     * 补货单分类汇总
     */
    @PostMapping(value = "/replenishmentCount")
    public ReplenishmentTotalDTO countNum(@RequestBody ReplenishmentQueryPageRequest queryPageRequest) {
        ReplenishmentQueryRequest replenishmentQueryRequest = replenishmentDTOConverter.req2PageDTO(queryPageRequest);
        return replenishmentAndroidFacade.queryCount(replenishmentQueryRequest);
    }


    }
